package com.ihrm.employee.service;

import com.ihrm.domain.employee.EmployeePositive;
import com.ihrm.employee.dao.PositiveDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Optional;

@Service
public class PositiveService {

    @Autowired
    private PositiveDao positiveDao;
    
    public EmployeePositive findById(String uid,Integer status){
        EmployeePositive positive = positiveDao.findByUserId(uid);
        if(status!=null&&positive!=null){
            if(positive.getEstatus() != (int)status){
                positive=null;
            }
        }
        return positive;
    }
    
    public EmployeePositive findById(String uid){
        return positiveDao.findByUserId(uid);
    }
    
    public void save(EmployeePositive positive){
        positive.setCreateTime(new Date());
        /**
         * 未执行
         */
        positive.setEstatus(1);
        positiveDao.save(positive);
    }
    

}
